<body>
    <div class="x-body">
        <form class="layui-form">
            <input type="hidden" name="key" value="{$key}">
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    序号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="id" name="id" required="" lay-verify="required"
                    autocomplete="off"  value="{$data['id']}" class="layui-input" disabled="true">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red">*</span>链接名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" required="" lay-verify="required"
                    autocomplete="off"  value="{$data['title']}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="link" class="layui-form-label">
                    <span class="x-red">*</span>URL
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="link" name="link" required="" lay-verify="required"
                    autocomplete="off" value="{$data['link']}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="sort" class="layui-form-label">
                    <span class="x-red">*</span>排序
                </label>
                <div class="layui-input-inline">
                    <input type="number" id="sort" name="sort" required="" lay-verify="required"
                    autocomplete="off" value="{$data['link_sort']}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="save" lay-submit="">
                    保存
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form()
          ,layer = layui.layer;
        

          //监听提交
          form.on('submit(save)', function(data){
            console.log(data);
            //发异步，把数据提交给php
            $.post('{:U("admin/system/sys_link")}', {edit: data.field}, function(response) {
                console.log(response);
                layer.msg(response.info, {icon: 6},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                    parent.location.reload();
                });
            });
            //刷新父窗口
            return false;
          });
          
        });
    </script>
</body>